using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Perovich.GameObjects
{
#if WINDOWS_PHONE || XBOX
    public class HashSet<T> : ICollection<T>
    {
        private Dictionary<T, short> set;

        public HashSet()
        {
            set = new Dictionary<T, short>();
        }


        #region ICollection<T> Members

        public void Add(T item)
        {
            set.Add(item, 0);
        }

        public void Clear()
        {
            set.Clear();
        }

        public bool Contains(T item)
        {
            return set.ContainsKey(item);
        }

        public void CopyTo(T[] array, int arrayIndex)
        {
            throw new NotImplementedException();
        }

        public int Count
        {
            get { return set.Count; }
        }

        public bool IsReadOnly
        {
            get { return false; }
        }

        public bool Remove(T item)
        {
            return set.Remove(item);
        }

        #endregion

        #region IEnumerable<T> Members

        public IEnumerator<T> GetEnumerator()
        {
            foreach (var k in set)
            {
                yield return k.Key;
            }
        }

        #endregion

        #region IEnumerable Members

        System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
        {
            foreach (var k in set)
            {
                yield return k.Key;
            }
        }

        #endregion

    }
#endif
}
